package com.service.impl;

import com.dao.CommentDao;
import com.dao.TravelDao;
import com.domain.Comment;
import com.domain.Travel;
import com.service.TravelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;

@Service("travelService")
public class TravelServiceImp implements TravelService {

    @Autowired
    private TravelDao travelDao;

    @Autowired
    private CommentDao commentDao;


    @Override
    public List<Comment> findCommentsByTravelId(Integer travelid) {
        return commentDao.findCommentsByTravelId(travelid);
    }

    @Override
    public Boolean commitOneComment(Comment comment) {
        int r= commentDao.addOneComment(comment);
        if (r==1){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean commitOneTravel(Travel travel) {
        int r= travelDao.addOneTravel(travel);
        if (r==1){
            return true;
        }else{
            return false;
        }
    }

    @Override
    public List<Travel> findAllTravel() {
        return travelDao.findAllTravel();
    }

    @Override
    public Travel findTravelById(Integer travelid) {
        return travelDao.getOneTravel(travelid);
    }


}
